home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!snorkelwacker!apple!netcom!amdcad!sun!mipsdal.mips.com
- From: riley@mipsdal.mips.com (Riley Rainey)
- Newsgroups: comp.sources.x
- Subject: v09i073: acm, X aerial combat simulation, Part05/05
- Message-ID: <143452@sun.Eng.Sun.COM>
- Date: 7 Oct 90 18:13:26 GMT
- References: <csx-09i069:acm@uunet.UU.NET>
- Sender: news@sun.Eng.Sun.COM
- Lines: 1417
- Approved: argv@sun.com
-
- Submitted-by: riley@mipsdal.mips.com (Riley Rainey)
- Posting-number: Volume 9, Issue 73
- Archive-name: acm/part05
-
- echo x - ./fsim/server.c
- sed 's/^X//' >./fsim/server.c <<'*-*-END-of-./fsim/server.c-*-*'
- X/*
- X * xflight : an aerial combat simulator for X
- X *
- X * Written by Riley Rainey, riley@mips.com
- X *
- X * Permission to use, copy, modify and distribute (without charge) this
- X * software, documentation, images, etc. is granted, provided that this
- X * comment and the author's name is retained.
- X *
- X */
- X
- X#include "manifest.h"
- X#include <sys/types.h>
- X#include <stdio.h>
- X#include <pwd.h>
- X#include <signal.h>
- X#include <sys/socket.h>
- X#include <sys/ioctl.h>
- X#include <sys/time.h>
- X#include <netinet/in.h>
- X#include <netdb.h>
- X#include <setjmp.h>
- X
- Xextern struct servent *getservent();
- Xint sdebug = 1;
- Xint listen_socket;
- X
- Xvoid parseinfo (s, a, b, c)
- Xchar *s, *a, *b, *c; {
- X
- X char *p;
- X
- X for (p=a; *s; ++s, ++p)
- X if ((*p = *s) == ' ') {
- X *p = '\0';
- X break;
- X }
- X
- X ++ s;
- X
- X for (p=b; *s; ++s, ++p)
- X if ((*p = *s) == ' ') {
- X *p = '\0';
- X break;
- X }
- X
- X ++ s;
- X
- X strcpy (c, s);
- X
- X return;
- X}
- X
- Xmain (argc, argv)
- Xint argc;
- Xchar *argv[]; {
- X
- X struct sockaddr_in sin;
- X struct servent *sp;
- X int on = 1;
- X int i, background = 0;
- X
- X/*
- X * parse arguments
- X */
- X
- X for (i=1; i<argc; ++i) {
- X
- X if (*argv[i] == '-')
- X switch (*(argv[i]+1)) {
- X
- X case 'b':
- X background = 1;
- X break;
- X
- X default:
- X fprintf (stderr, "Invalid switch \"%s\"\n", argv[i]);
- X break;
- X }
- X }
- X
- X if (sdebug) {
- X/*
- X if ((sp = getservbyname ("acm", "tcp");
- X fprintf (stderr, "can't find acm service\n");
- X exit (1);
- X }
- X*/
- X
- X if ((listen_socket = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
- X perror ("socket");
- X exit (1);
- X }
- X
- X sin.sin_family = AF_INET;
- X sin.sin_addr.s_addr = INADDR_ANY;
- X sin.sin_port = htons(ACM_PORT);
- X
- X if (bind (listen_socket, &sin, sizeof(sin)) < 0) {
- X perror ("bind");
- X exit (1);
- X }
- X }
- X else {
- X listen_socket = 0; /* inetd sets this up for us */
- X/* freopen ("/people/riley/acm.error", "a", stderr); */
- X }
- X
- X (void) setsockopt(listen_socket, SOL_SOCKET, SO_REUSEADDR,
- X (char *) &on, sizeof on);
- X (void) setsockopt(listen_socket, SOL_SOCKET, SO_KEEPALIVE,
- X (char *) &on, sizeof on);
- X ioctl(listen_socket, FIONBIO, (char *) &on);
- X
- X if (listen (listen_socket, 5) < 0) {
- X perror ("listen");
- X close (listen_socket);
- X exit (1);
- X }
- X
- X if (background)
- X#ifdef SYSV
- X setpgrp (1);
- X#else
- X setpgrp (0, 1);
- X#endif
- X
- X init ();
- X input();
- X
- X}
- X
- Xint peerdied = 0;
- X
- Xdeadpeer () {
- X fprintf (stderr, "SIGPIPE\n");
- X peerdied = 1;
- X}
- X
- Xstruct sigvec alrm, pipe;
- Xint doUpdate = 0;
- X
- Xmyalarm () {
- X doUpdate++;
- X sigvec (SIGALRM, &alrm, (struct sigvec *) 0);
- X}
- X
- Xinput () {
- X
- X fd_set fdset, ofdset;
- X int nplayers = 0, news = -1, playerchange = 0, n, pno, addrlen;
- X int on = 1;
- X struct sockaddr addr;
- X struct itimerval update;
- X char *bp, buf[128], name[64], display[64], args[128];
- X
- X alrm.sv_handler = myalarm;
- X alrm.sv_mask = 0;
- X alrm.sv_flags = SV_INTERRUPT;
- X sigvec (SIGALRM, &alrm, (struct sigvec *) 0);
- X
- X/*
- X * Set real time clock to interrupt us every UPDATE_INTERVAL usecs.
- X */
- X
- X update.it_interval.tv_sec = 0;
- X update.it_interval.tv_usec = UPDATE_INTERVAL;
- X update.it_value.tv_sec = 0;
- X update.it_value.tv_usec = UPDATE_INTERVAL;
- X setitimer (ITIMER_REAL, &update, 0);
- X
- X pipe.sv_handler = SIG_DFL;
- X pipe.sv_mask = 0;
- X pipe.sv_flags = SV_INTERRUPT;
- X sigvec (SIGPIPE, &pipe, (struct sigvec *) 0);
- X
- X FD_ZERO (&ofdset);
- X FD_ZERO (&fdset);
- X FD_SET (listen_socket, &ofdset);
- X
- X for (;;) {
- X
- X sigsetmask (0);
- X
- X fdset = ofdset;
- X pno = select (32, &fdset, (fd_set *) NULL, (fd_set *) NULL,
- X (struct itimerval *) NULL);
- X
- X sigblock (SIGALRM);
- X
- X if (pno < 0) {
- X FD_CLR (listen_socket, &fdset);
- X if (news > 0)
- X FD_CLR (news, &fdset);
- X }
- X
- X if (FD_ISSET (listen_socket, &fdset) ||
- X (news > 0 && FD_ISSET(news, &fdset))) {
- X if (news == -1) {
- X addrlen = sizeof (addr);
- X news = accept(listen_socket, &addr, &addrlen);
- X if (news > 0) {
- X peerdied = 0;
- X pipe.sv_handler = deadpeer;
- X sigvec(SIGPIPE, &pipe, (struct sigvec *) 0);
- X ioctl (news, FIONBIO, &on);
- X FD_SET (news, &ofdset);
- X bp = buf;
- X }
- X }
- X if (news > 0) {
- X if ((n = read (news, bp, 1)) > 0) {
- X if (*bp == '\n') {
- X *bp = '\0';
- X parseinfo (buf, display,
- X name, args);
- X if (newPlayer (news,
- X display, name, args) == 0)
- X write (news, "Ready.\n", 7);
- X printf ("%s\n", display);
- X close (news);
- X news = -1;
- X }
- X else
- X bp++;
- X playerchange = 1;
- X }
- X if (n == 0)
- X peerdied = 1;
- X }
- X }
- X
- X if (playerchange) {
- X FD_ZERO (&ofdset);
- X FD_SET (listen_socket, &ofdset);
- X if (news >= 0)
- X FD_SET (news, &ofdset);
- X pipe.sv_handler = SIG_DFL;
- X sigvec (SIGPIPE, &pipe, (struct sigvec *) 0);
- X playerchange = 0;
- X }
- X
- X if (doUpdate) {
- X doUpdate = 0;
- X redraw ();
- X }
- X
- X }
- X}
- *-*-END-of-./fsim/server.c-*-*
- echo x - ./fsim/scale.h
- sed 's/^X//' >./fsim/scale.h <<'*-*-END-of-./fsim/scale.h-*-*'
- Xtypedef struct {
- X int xorg; /* x loc of bottom of scale */
- X int yorg; /* y loc of bottom of scale */
- X int length; /* length of scale (pixels) */
- X int orientation; /* orientation flags */
- X double scale; /* units per pixel */
- X int minorInterval; /* units per minor tick */
- X int minorSize; /* width of minor ticks (pixels) */
- X int majorInterval; /* units per major tick */
- X int majorSize; /* width of major ticks (pixels) */
- X int indexSize; /* width of index (pixels) */
- X double divisor; /* divisor on digit scale */
- X char *format; /* output format */
- X } scaleControl;
- X
- X#define orientRight 1
- X#define orientHorizontal 2
- *-*-END-of-./fsim/scale.h-*-*
- echo x - ./fsim/eng.xbm
- sed 's/^X//' >./fsim/eng.xbm <<'*-*-END-of-./fsim/eng.xbm-*-*'
- X#define eng_width 64
- X#define eng_height 64
- X#define eng_x_hot 31
- X#define eng_y_hot 31
- Xstatic char eng_bits[] = {
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
- X 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x01, 0x00, 0x00,
- X 0x00, 0x00, 0xf8, 0x03, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x36, 0xc0,
- X 0x01, 0x36, 0x00, 0x00, 0x00, 0x00, 0x0d, 0xc0, 0x01, 0x58, 0x00, 0x00,
- X 0x00, 0xc0, 0x03, 0x80, 0x00, 0xe0, 0x01, 0x00, 0x00, 0xe0, 0x00, 0x80,
- X 0x00, 0x80, 0x03, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
- X 0x00, 0x14, 0x00, 0xc0, 0x00, 0x00, 0x14, 0x00, 0x00, 0x0a, 0x00, 0x20,
- X 0x01, 0x00, 0x28, 0x00, 0x00, 0x05, 0x00, 0x20, 0x01, 0x00, 0x52, 0x00,
- X 0x00, 0x03, 0x00, 0x20, 0x01, 0x00, 0x64, 0x00, 0x80, 0x01, 0x00, 0x20,
- X 0x01, 0x00, 0xce, 0x00, 0xc0, 0x00, 0x00, 0x20, 0x01, 0x00, 0x83, 0x01,
- X 0xc0, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x80, 0x01, 0x60, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x03, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
- X 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x28, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x0a, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c,
- X 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
- X 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x18, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
- X 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x06, 0x62, 0x0c, 0x00,
- X 0x00, 0x80, 0x31, 0x30, 0x06, 0x93, 0x12, 0x00, 0x00, 0x40, 0x48, 0x30,
- X 0x76, 0x92, 0x12, 0x00, 0x00, 0x40, 0x48, 0x37, 0x56, 0x92, 0x12, 0x80,
- X 0x00, 0x80, 0x49, 0x35, 0x76, 0x92, 0x12, 0x00, 0x00, 0x40, 0x4a, 0x37,
- X 0x06, 0x92, 0x12, 0x00, 0x00, 0x40, 0x4a, 0x30, 0x06, 0x67, 0x0c, 0x00,
- X 0x00, 0x80, 0x31, 0x30, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
- X 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0xe7,
- X 0x44, 0x00, 0x00, 0x18, 0x0c, 0x00, 0x00, 0x29, 0x45, 0x00, 0x00, 0x18,
- X 0x0c, 0x00, 0x00, 0x29, 0x6d, 0x00, 0x00, 0x18, 0x0c, 0x00, 0x00, 0xe7,
- X 0x54, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x23, 0x54, 0x00, 0x00, 0x0c,
- X 0x18, 0x00, 0x00, 0x2d, 0x44, 0x00, 0x00, 0x0c, 0x28, 0x00, 0x00, 0x29,
- X 0x44, 0x00, 0x00, 0x0a, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
- X 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x60, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x10, 0x80, 0x01,
- X 0xc0, 0x40, 0x00, 0x30, 0x06, 0x00, 0x81, 0x01, 0x80, 0x69, 0x00, 0x48,
- X 0x09, 0x00, 0xcb, 0x00, 0x00, 0x33, 0x00, 0x48, 0x09, 0x00, 0x66, 0x00,
- X 0x00, 0x25, 0x00, 0x30, 0x09, 0x00, 0x52, 0x00, 0x00, 0x0a, 0x00, 0x48,
- X 0x09, 0x00, 0x28, 0x00, 0x00, 0x14, 0x00, 0x48, 0x09, 0x00, 0x14, 0x00,
- X 0x00, 0x38, 0x00, 0x30, 0x06, 0x00, 0x0e, 0x00, 0x00, 0xe0, 0x00, 0x80,
- X 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x03, 0x80, 0x00, 0xe0, 0x01, 0x00,
- X 0x00, 0x00, 0x0d, 0x40, 0x01, 0x58, 0x00, 0x00, 0x00, 0x00, 0x36, 0xc0,
- X 0x01, 0x36, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0xe0, 0x0f, 0x00, 0x00,
- X 0x00, 0x00, 0xc0, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
- X 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- *-*-END-of-./fsim/eng.xbm-*-*
- echo x - ./fsim/getStick.c
- sed 's/^X//' >./fsim/getStick.c <<'*-*-END-of-./fsim/getStick.c-*-*'
- X/*
- X * xflight : an aerial combat simulator for X
- X *
- X * Written by Riley Rainey, riley@mips.com
- X *
- X * Permission to use, copy, modify and distribute (without charge) this
- X * software, documentation, images, etc. is granted, provided that this
- X * comment and the author's name is retained.
- X *
- X */
- X
- X#include "pm.h"
- X#include <math.h>
- X
- X/*
- X * getStick : get stick input from mouse
- X * inputs Sa and Se range from -1.0 to 1.0.
- X */
- X
- Xint getStick (c, u)
- Xcraft *c;
- Xviewer *u; {
- X
- X int rootX, rootY, x, y;
- X Window root, child;
- X unsigned int mask;
- X double d, fuzz;
- X
- X if (XQueryPointer (u->dpy, u->win, &root, &child, &rootX, &rootY,
- X &x, &y, &mask) == True) {
- X
- X if (x >= 0 && y >= 0 && x < u->width && y < u->height) {
- X
- X fuzz = (double) u->width / 48.0;
- X x = x - u->xCenter;
- X y = y - u->yCenter;
- X d = sqrt ((double)(x*x + y*y));
- X
- X if (d > fuzz) {
- X c->Sa=(double) x / (double) u->xCenter * (d-fuzz) / d;
- X c->Se=(double) y / (double) u->yCenter * (d-fuzz) / d;
- X#ifndef LINEAR_CONTROL_RESPONSE
- X if (c->Sa < 0.0)
- X c->Sa = - c->Sa * c->Sa;
- X else
- X c->Sa = c->Sa * c->Sa;
- X
- X if (c->Se < 0.0)
- X c->Se = - c->Se * c->Se;
- X else
- X c->Se = c->Se * c->Se;
- X#endif
- X }
- X else {
- X c->Sa = 0.0;
- X c->Se = 0.0;
- X }
- X return 1;
- X
- X }
- X }
- X
- X return 0;
- X}
- *-*-END-of-./fsim/getStick.c-*-*
- echo x - ./fsim/header
- sed 's/^X//' >./fsim/header <<'*-*-END-of-./fsim/header-*-*'
- X/*
- X * xflight : an aerial combat simulator for X
- X *
- X * Written by Riley Rainey, riley@mips.com
- X *
- X * Permission to use, copy, modify and distribute (without charge) this
- X * software, documentation, images, etc. is granted, provided that this
- X * comment and the author's name is retained.
- X *
- *-*-END-of-./fsim/header-*-*
- echo x - ./fsim/rwy2
- sed 's/^X//' >./fsim/rwy2 <<'*-*-END-of-./fsim/rwy2-*-*'
- XRunway
- X4 1
- X1 0 -75.000000 0
- X2 12000 -75 0
- X3 12000 75.000000 0
- X4 0 75.000000 0
- X#b7b19f 4 1 2 3 4
- *-*-END-of-./fsim/rwy2-*-*
- echo x - ./fsim/droneCalculations.c
- sed 's/^X//' >./fsim/droneCalculations.c <<'*-*-END-of-./fsim/droneCalculations.c-*-*'
- X/*
- X * xflight : an aerial combat simulator for X
- X *
- X * Written by Riley Rainey, riley@mips.com
- X *
- X * Permission to use, copy, modify and distribute (without charge) this
- X * software, documentation, images, etc. is granted, provided that this
- X * comment and the author's name is retained.
- X *
- X */
- X
- X#include "pm.h"
- X
- X/*
- X * Drone flight management
- X */
- X
- Xint droneCalculations (c)
- Xcraft *c; {
- X
- X c->prevSg = c->Sg;
- X
- X c->Sg.x += c->Cg.x * deltaT;
- X c->Sg.y += c->Cg.y * deltaT;
- X c->Sg.z += c->Cg.z * deltaT;
- X
- X/*
- X * Don't let drones get above 60 thousand feet
- X */
- X
- X if (c->Sg.z < -60000.0)
- X return 1;
- X
- X/*
- X * Drone crash detection
- X */
- X
- X if (c->Sg.z > 0.0)
- X return 1;
- X
- X return 0;
- X}
- *-*-END-of-./fsim/droneCalculations.c-*-*
- echo x - ./fsim/flaps1.xbm
- sed 's/^X//' >./fsim/flaps1.xbm <<'*-*-END-of-./fsim/flaps1.xbm-*-*'
- X#define flaps1_width 64
- X#define flaps1_height 32
- X#define flaps1_x_hot -1
- X#define flaps1_y_hot -1
- Xstatic char flaps1_bits[] = {
- X 0x00, 0xf0, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0xde, 0xdd, 0xfd,
- X 0x1f, 0x00, 0x00, 0x00, 0x60, 0xef, 0xee, 0xee, 0xee, 0xff, 0x03, 0x00,
- X 0x70, 0x77, 0x77, 0x77, 0x77, 0xf7, 0x3f, 0x00, 0x58, 0xbb, 0xbb, 0xbb,
- X 0xbb, 0x7b, 0x01, 0x00, 0x48, 0xdf, 0xdd, 0xdd, 0xdd, 0x3d, 0x0f, 0x00,
- X 0xe8, 0xfe, 0xff, 0xff, 0xff, 0x9f, 0x3f, 0x00, 0x38, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00};
- *-*-END-of-./fsim/flaps1.xbm-*-*
- echo x - ./fsim/aim-9
- sed 's/^X//' >./fsim/aim-9 <<'*-*-END-of-./fsim/aim-9-*-*'
- X#
- X63 4
- X1 -0.9167 0 0
- X2 -0.9167 0.0833 0
- X3 -1 0.1667 0
- X4 -1.6667 0.25 0
- X5 -1.8333 0.25 0
- X6 -2.3333 0.8333 0
- X7 -2.4167 1 0
- X8 -2.4167 0.25 0
- X9 -7.5833 0.25 0
- X10 -8 1 0
- X11 -9 1 0
- X12 -9 -1 0
- X13 -8 -1 0
- X14 -7.5833 -0.25 0
- X15 -2.4167 -0.25 0
- X16 -2.4167 -1 0
- X17 -2.3333 -0.8333 0
- X18 -1.8333 -0.25 0
- X19 -1.6667 -0.25 0
- X20 -1 -0.1667 0
- X21 -0.9167 -0.0833 0
- X1 -0.9167 0 0
- X2 -0.9167 0 0.0833
- X3 -1 0 0.1667
- X4 -1.6667 0 0.25
- X5 -1.8333 0 0.25
- X6 -2.3333 0 0.8333
- X7 -2.4167 0 1
- X8 -2.4167 0 0.25
- X9 -7.5833 0 0.25
- X10 -8 0 1
- X11 -9 0 1
- X12 -9 0 -1
- X13 -8 0 -1
- X14 -7.5833 0 -0.25
- X15 -2.4167 0 -0.25
- X16 -2.4167 0 -1
- X17 -2.3333 0 -0.8333
- X18 -1.8333 0 -0.25
- X19 -1.6667 0 -0.25
- X20 -1 0 -0.1667
- X21 -0.9167 0 -0.0833
- X43 -9 0.25 0
- X44 -9 0.1768 0.1768
- X45 -9 0 0.25
- X46 -9 -0.1768 0.1768
- X47 -9 -0.25 0
- X48 -9 -0.1768 -0.1768
- X49 -9 0 -0.25
- X50 -9 0.1768 -0.1768
- X51 -9 -0.25 0
- X52 -9.75 -0.5 0
- X53 -12 -0.75 0
- X54 -13.5 -0.75 0
- X55 -12.75 -0.5 0
- X56 -15.25 -0.5 0
- X57 -19.9167 0 0
- X58 -15.0833 0.4167 0
- X59 -15.75 0.5 0
- X60 -12.5833 0.6667 0
- X61 -12.0833 0.5833 0
- X62 -9.833 0.5 0
- X63 -9 0.25 0
- Xwhite 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
- Xwhite 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
- Xwhite 8 43 44 45 46 47 48 49 50
- Xwhite 13 51 52 53 54 55 56 57 58 59 60 61 62 63
- *-*-END-of-./fsim/aim-9-*-*
- echo x - ./fsim/missileCalculations.c
- sed 's/^X//' >./fsim/missileCalculations.c <<'*-*-END-of-./fsim/missileCalculations.c-*-*'
- X/*
- X * xflight : an aerial combat simulator for X
- X *
- X * Written by Riley Rainey, riley@mips.com
- X *
- X * Permission to use, copy, modify and distribute (without charge) this
- X * software, documentation, images, etc. is granted, provided that this
- X * comment and the author's name is retained.
- X *
- X */
- X
- X#include <stdio.h>
- X#include <math.h>
- X#include "pm.h"
- X
- Xint mdebug = 0;
- Xextern double calcRho();
- X
- Xint missileCalculations (c)
- Xcraft *c; {
- X
- X double q, rho, CLift, CDrag;
- X double FLift, FDrag, FWeight;
- X double Vmag, angle;
- X double deltaRoll, deltaPitch, deltaYaw;
- X VPoint F, Fg, tmpPt, r;
- X VMatrix turn, tmpMatrix, mtx;
- X
- X/*
- X * Check for ground impact. We do this at the beginning to permit us to
- X * kill ground targets.
- X */
- X
- X if (c->Sg.z > 0.0) {
- X killMissile (c);
- X return 1;
- X }
- X
- X trackTarget (c);
- X
- X -- c->armFuse;
- X
- X/*
- X * Re-orient the body of the missile towards it's intended target.
- X */
- X
- X c->prevSg = c->Sg;
- X
- X rho = calcRho (-(c->Sg.z));
- X
- X/*
- X * Compute the resultant force vector on the missile.
- X */
- X
- X Vmag = mag(c->Cg);
- X q = rho * c->cinfo->wingS * Vmag * Vmag * 0.5;
- X FLift = 0.0;
- X FDrag = c->cinfo->CDOrigin * q;
- X
- X if (mdebug) {
- X printf ("rho = %g, FLift = %g, FDrag = %g\n", rho, FLift, FDrag);
- X printf ("FThrust = %g\n", c->curThrust);
- X }
- X
- X F.x = c->curThrust - FDrag;
- X F.y = 0.0;
- X F.z = 0.0;
- X
- X/*
- X * Now calculate changes in position (Sg) and velocity (Cg).
- X */
- X
- X if ((c->fuel -= fuelUsed(c)) <= 0.0) {
- X if (c->curThrust > 0.0)
- X if (mdebug)
- X printf ("Missile burnout; velocity = %g fps (%g kts)\n", Vmag,
- X FPStoKTS(Vmag));
- X c->fuel = 0.0;
- X c->curThrust = 0.0;
- X }
- X
- X/*
- X * Normalize picth and heading Euler angles
- X */
- X
- X if (c->curPitch > pi / 2.0) {
- X c->curPitch = pi - c->curPitch;
- X c->curHeading = (c->curHeading > pi) ?
- X c->curHeading - pi : c->curHeading + pi;
- X c->curRoll = pi - c->curRoll;
- X }
- X else if (c->curPitch < -pi/2.0) {
- X c->curPitch = -pi - c->curPitch;
- X c->curHeading = (c->curHeading > pi) ?
- X c->curHeading - pi : c->curHeading + pi;
- X c->curRoll = pi - c->curRoll;
- X }
- X
- X if (c->curHeading < 0.0) {
- X c->curHeading += 2.0 * pi;
- X }
- X else if (c->curHeading > 2.0 * pi) {
- X c->curHeading -= 2.0 * pi;
- X }
- X
- X/*
- X * Compute transformation matricies
- X */
- X
- X VIdentMatrix (&mtx);
- X if (c->curRoll != 0.0)
- X VRotate (&mtx, XRotation, c->curRoll);
- X if (c->curPitch != 0.0)
- X VRotate (&mtx, YRotation, -c->curPitch);
- X if (c->curHeading != 0.0)
- X VRotate (&mtx, ZRotation, c->curHeading);
- X c->trihedral = mtx;
- X
- X transpose (&c->trihedral, &c->Itrihedral);
- X
- X craftToGround (c, &F, &Fg);
- X FWeight = c->cinfo->emptyWeight + c->fuel;
- X Fg.z += FWeight;
- X
- X if (mdebug) {
- X printf ("v = %g, Fg = { %g, %g, %g }\n", FPStoKTS(Vmag),
- X Fg.x, Fg.y, Fg.z);
- X printf ("F = { %g, %g, %g }\n", F.x, F.y, F.z);
- X }
- X
- X
- X
- X/*
- X * Update the missile's position and velocity.
- X */
- X
- X
- X c->Sg.x += c->Cg.x * deltaT + Fg.x / FWeight * a * halfDeltaTSquared;
- X c->Sg.y += c->Cg.y * deltaT + Fg.y / FWeight * a * halfDeltaTSquared;
- X c->Sg.z += c->Cg.z * deltaT + Fg.z / FWeight * a * halfDeltaTSquared;
- X
- X c->Cg.x += Fg.x / FWeight * a * deltaT;
- X c->Cg.y += Fg.y / FWeight * a * deltaT;
- X c->Cg.z += Fg.z / FWeight * a * deltaT;
- X
- X
- X if (mdebug) {
- X printf ("Altitude = %g\n", -c->Sg.z);
- X printf ("Euler angles { %g, %g, %g }\n", RADtoDEG(c->curRoll),
- X RADtoDEG(c->curPitch), RADtoDEG(c->curHeading));
- X printf ("Cg = { %g, %g, %g }\n", c->Cg.x, c->Cg.y, c->Cg.z);
- X printf ("Sg = { %g, %g, %g }\n", c->Sg.x, c->Sg.y, c->Sg.z);
- X }
- X
- X return 0;
- X}
- *-*-END-of-./fsim/missileCalculations.c-*-*
- echo x - ./fsim/flaps2.xbm
- sed 's/^X//' >./fsim/flaps2.xbm <<'*-*-END-of-./fsim/flaps2.xbm-*-*'
- X#define flaps2_width 64
- X#define flaps2_height 32
- X#define flaps2_x_hot -1
- X#define flaps2_y_hot -1
- Xstatic char flaps2_bits[] = {
- X 0x00, 0xf0, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0xdd, 0xfd,
- X 0x1f, 0x00, 0x00, 0x00, 0x20, 0xef, 0xee, 0xee, 0xee, 0xff, 0x03, 0x00,
- X 0x30, 0x77, 0x77, 0x77, 0x77, 0xf7, 0x3f, 0x00, 0x38, 0xbb, 0xbb, 0xbb,
- X 0xbb, 0x7b, 0x00, 0x00, 0x28, 0xdf, 0xdd, 0xdd, 0xdd, 0x3d, 0x0e, 0x00,
- X 0x6c, 0xfe, 0xff, 0xff, 0xff, 0x1f, 0x1e, 0x00, 0x3c, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x3c, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00};
- *-*-END-of-./fsim/flaps2.xbm-*-*
- echo x - ./fsim/flaps.c
- sed 's/^X//' >./fsim/flaps.c <<'*-*-END-of-./fsim/flaps.c-*-*'
- X/*
- X * xflight : an aerial combat simulator for X
- X *
- X * Written by Riley Rainey, riley@mips.com
- X *
- X * Permission to use, copy, modify and distribute (without charge) this
- X * software, documentation, images, etc. is granted, provided that this
- X * comment and the author's name is retained.
- X *
- X */
- X
- X#include "pm.h"
- X
- Xint flapsDown (c)
- Xcraft *c; {
- X
- X c->flapSetting += 10.0 * pi / 180.0;
- X if (c->flapSetting > c->cinfo->maxFlap)
- X c->flapSetting = c->cinfo->maxFlap;
- X return 0;
- X}
- X
- Xint flapsUp (c)
- Xcraft *c; {
- X
- X c->flapSetting -= 10.0 * pi / 180.0;
- X if (c->flapSetting < 0.0)
- X c->flapSetting = 0.0;
- X return 0;
- X}
- X
- Xvoid flapControl (c)
- Xcraft *c; {
- X
- X if (c->flapSetting > c->curFlap) {
- X c->curFlap += c->cinfo->flapRate * deltaT;
- X if (c->curFlap > c->flapSetting)
- X c->curFlap = c->flapSetting;
- X }
- X else if (c->flapSetting < c->curFlap) {
- X c->curFlap -= c->cinfo->flapRate * deltaT;
- X if (c->curFlap < c->flapSetting)
- X c->curFlap = c->flapSetting;
- X }
- X
- X if (c->speedBrakeSetting > c->curSpeedBrake) {
- X c->curSpeedBrake += c->cinfo->speedBrakeRate * deltaT;
- X if (c->curSpeedBrake > c->speedBrakeSetting)
- X c->curSpeedBrake = c->speedBrakeSetting;
- X }
- X else if (c->speedBrakeSetting < c->curSpeedBrake) {
- X c->curSpeedBrake -= c->cinfo->speedBrakeRate * deltaT;
- X if (c->curSpeedBrake < c->speedBrakeSetting)
- X c->curSpeedBrake = c->speedBrakeSetting;
- X }
- X}
- X
- Xint speedBrakeExtend (c)
- Xcraft *c; {
- X
- X c->speedBrakeSetting += c->cinfo->speedBrakeIncr;
- X if (c->speedBrakeSetting > c->cinfo->maxSpeedBrake)
- X c->speedBrakeSetting = c->cinfo->maxSpeedBrake;
- X return 0;
- X}
- X
- Xint speedBrakeRetract (c)
- Xcraft *c; {
- X
- X c->speedBrakeSetting -= c->cinfo->speedBrakeIncr;
- X if (c->speedBrakeSetting < 0.0)
- X c->speedBrakeSetting = 0.0;
- X return 0;
- X}
- *-*-END-of-./fsim/flaps.c-*-*
- echo x - ./fsim/exp1.xbm
- sed 's/^X//' >./fsim/exp1.xbm <<'*-*-END-of-./fsim/exp1.xbm-*-*'
- X#define exp1_width 64
- X#define exp1_height 64
- X#define exp1_x_hot -1
- X#define exp1_y_hot -1
- Xstatic char exp1_bits[] = {
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
- X 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x81, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x20, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
- X 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x80, 0x61, 0x00, 0x03,
- X 0x00, 0x00, 0x00, 0x20, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, 0x40,
- X 0x80, 0x20, 0x80, 0x01, 0x00, 0x80, 0x40, 0x40, 0x80, 0x38, 0x80, 0x01,
- X 0x00, 0x80, 0x01, 0xa0, 0x82, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00,
- X 0x82, 0x22, 0x00, 0x00, 0x00, 0x00, 0x06, 0x80, 0xc4, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x06, 0x02, 0x10, 0x00, 0x80, 0x00, 0x0c, 0x80,
- X 0xa9, 0x00, 0x00, 0x00, 0x00, 0x01, 0xa8, 0x10, 0x93, 0x75, 0x02, 0x20,
- X 0x00, 0x00, 0xe0, 0x04, 0x3e, 0x03, 0x01, 0x20, 0x00, 0x04, 0x10, 0x92,
- X 0x8a, 0x0e, 0x06, 0x1a, 0x00, 0x5c, 0x81, 0xf1, 0xef, 0x1b, 0x80, 0x01,
- X 0x00, 0x18, 0x80, 0x0c, 0xcb, 0x01, 0xa5, 0x00, 0x00, 0x60, 0x88, 0x17,
- X 0x43, 0x07, 0x87, 0x00, 0x00, 0xa0, 0x21, 0x79, 0xc7, 0x51, 0x23, 0x00,
- X 0x00, 0x80, 0x40, 0x3f, 0xeb, 0x1e, 0x07, 0x00, 0x00, 0x00, 0x40, 0x1f,
- X 0xef, 0xb8, 0x17, 0x00, 0x00, 0x04, 0x04, 0x06, 0x2c, 0x71, 0x06, 0x00,
- X 0x00, 0x08, 0x00, 0x6b, 0x5f, 0x10, 0x02, 0x00, 0x00, 0x40, 0xf9, 0x38,
- X 0x01, 0xbf, 0x01, 0x00, 0x00, 0x00, 0xac, 0xb3, 0x5f, 0xfd, 0x03, 0x00,
- X 0x00, 0x00, 0xfc, 0xb9, 0x4f, 0xa7, 0x03, 0x10, 0x00, 0x00, 0xd7, 0xac,
- X 0xc2, 0x9a, 0x0d, 0x04, 0x10, 0x40, 0x7b, 0xc9, 0x98, 0x79, 0x11, 0x18,
- X 0x00, 0xc0, 0xfa, 0x8d, 0x18, 0xcb, 0x29, 0x02, 0x00, 0x80, 0xd8, 0x0d,
- X 0x88, 0x0b, 0x57, 0x08, 0x00, 0xc0, 0x0c, 0x39, 0x60, 0x1b, 0x00, 0x00,
- X 0x00, 0xd0, 0x64, 0x97, 0xc1, 0x73, 0x18, 0x03, 0x00, 0x6b, 0x81, 0x0e,
- X 0x01, 0xfb, 0x0c, 0x02, 0x00, 0x80, 0xdf, 0x15, 0x81, 0x54, 0xe8, 0x02,
- X 0x00, 0x00, 0xde, 0xff, 0xa2, 0xd9, 0x3c, 0x00, 0x00, 0x80, 0x3f, 0xde,
- X 0xc2, 0xac, 0x94, 0x00, 0x00, 0x00, 0x33, 0xde, 0xec, 0x0b, 0x1e, 0x02,
- X 0x00, 0xc0, 0x6c, 0x17, 0xe1, 0xe7, 0x1c, 0x02, 0x00, 0x50, 0x76, 0xfc,
- X 0xf7, 0xfe, 0x3f, 0x00, 0x00, 0x1c, 0x5d, 0x9c, 0xfa, 0xba, 0x09, 0x00,
- X 0x00, 0x04, 0x63, 0xcc, 0x0e, 0x8c, 0x89, 0x00, 0x00, 0x46, 0x82, 0x90,
- X 0x80, 0xbb, 0x12, 0x00, 0x00, 0x02, 0xe3, 0xd7, 0x89, 0x81, 0x23, 0x00,
- X 0x80, 0x81, 0x21, 0x83, 0x84, 0x89, 0x03, 0x00, 0x00, 0x00, 0x04, 0xf7,
- X 0xcc, 0xdb, 0xe3, 0x00, 0x20, 0xa0, 0x00, 0xa6, 0x7e, 0x0b, 0xb1, 0x01,
- X 0x20, 0x00, 0x00, 0x19, 0x6f, 0x4e, 0x8e, 0x00, 0x10, 0x00, 0x00, 0x1c,
- X 0xe0, 0x53, 0x06, 0x02, 0x00, 0x00, 0x00, 0x04, 0xe7, 0xa9, 0x00, 0x02,
- X 0x00, 0x00, 0x80, 0x43, 0x14, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38,
- X 0x00, 0x88, 0x00, 0x0c, 0x00, 0x00, 0xc0, 0x00, 0x0c, 0x40, 0x00, 0x08,
- X 0x00, 0x00, 0x40, 0x05, 0x08, 0x20, 0x01, 0x00, 0x00, 0x00, 0x60, 0x00,
- X 0x04, 0x00, 0x02, 0x18, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x03, 0x10,
- X 0x00, 0x01, 0x20, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x08, 0x08, 0x00,
- X 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80, 0x00,
- X 0x00, 0x80, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00, 0x10, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00};
- *-*-END-of-./fsim/exp1.xbm-*-*
- echo x - ./fsim/tower
- sed 's/^X//' >./fsim/tower <<'*-*-END-of-./fsim/tower-*-*'
- X*-a-control-tower
- X60 16
- X1 20 20 0
- X2 20 -20 0
- X3 12 -12 -60
- X4 12 12 -60
- X5 12 12 -60
- X6 12 -12 -60
- X7 12 -12 -64
- X8 12 12 -64
- X9 12 0.25 -64
- X10 12 -0.25 -64
- X11 12 -0.25 -72
- X12 12 0.25 -72
- X13 14 14 -72
- X14 14 -14 -72
- X15 0 0 -76
- X16 -20 -20 0
- X17 -20 20 0
- X18 -12 12 -60
- X19 -12 -12 -60
- X20 -12 -12 -60
- X21 -12 12 -60
- X22 -12 12 -64
- X23 -12 -12 -64
- X24 -12 -0.25 -64
- X25 -12 0.25 -64
- X26 -12 0.25 -72
- X27 -12 -0.25 -72
- X28 -14 -14 -72
- X29 -14 14 -72
- X30 0 0 -76
- X31 20 20 0
- X32 -20 20 0
- X33 -12 12 -60
- X34 12 12 -60
- X35 12 12 -60
- X36 -12 12 -60
- X37 -12 12 -64
- X38 12 12 -64
- X39 12 0.25 -64
- X40 -12 0.25 -64
- X41 -12 0.25 -72
- X42 12 0.25 -72
- X43 14 14 -72
- X44 -14 14 -72
- X45 0 0 -76
- X46 -20 -20 0
- X47 20 -20 0
- X48 12 -12 -60
- X49 -12 -12 -60
- X50 -12 -12 -60
- X51 12 -12 -60
- X52 12 -12 -64
- X53 -12 -12 -64
- X54 -12 -0.25 -64
- X55 12 -0.25 -64
- X56 12 -0.25 -72
- X57 -12 -0.25 -72
- X58 -14 -14 -72
- X59 14 -14 -72
- X60 0 0 -76
- Xgray33 4 1 2 3 4
- Xgray33 4 5 6 7 8
- Xgray33 4 9 10 11 12
- Xgray33 3 13 14 15
- Xgray33 4 16 17 18 19
- Xgray33 4 20 21 22 23
- Xgray33 4 24 25 26 27
- Xgray33 3 28 29 30
- Xgray33 4 31 32 33 34
- Xgray33 4 35 36 37 38
- Xgray33 4 39 40 41 42
- Xgray33 3 43 44 45
- Xgray33 4 46 47 48 49
- Xgray33 4 50 51 52 53
- Xgray33 4 54 55 56 57
- Xgray33 3 58 59 60
- *-*-END-of-./fsim/tower-*-*
- echo x - ./fsim/weapon.c
- sed 's/^X//' >./fsim/weapon.c <<'*-*-END-of-./fsim/weapon.c-*-*'
- X#include "pm.h"
- X
- Xint selectWeapon(c)
- Xcraft *c; {
- X
- X register int n, m;
- X
- X m = c->curWeapon;
- X n = (c->curWeapon + 1) % WEAPONTYPES;
- X for (; n != m; n = (n + 1) % WEAPONTYPES) {
- X if (wtbl[n].select != NULL)
- X if ((*wtbl[n].select)(c) == 1) {
- X c->curWeapon = n;
- X return 1;
- X }
- X }
- X
- X return 0;
- X}
- X
- Xint fireWeapon (c)
- Xcraft *c; {
- X
- X if (wtbl[c->curWeapon].firePress != NULL)
- X return (*wtbl[c->curWeapon].firePress)(c);
- X
- X return 0;
- X}
- X
- Xint ceaseFireWeapon (c)
- Xcraft *c; {
- X
- X if (wtbl[c->curWeapon].fireRelease != NULL)
- X return (*wtbl[c->curWeapon].fireRelease)(c);
- X
- X return 0;
- X}
- X
- Xint doWeaponDisplay (c, u)
- Xcraft *c;
- Xviewer *u; {
- X
- X int i;
- X
- X if (wtbl[c->curWeapon].display != NULL)
- X return (*wtbl[c->curWeapon].display)(c, wtbl[c->curWeapon].w, u);
- X else {
- X for (i=0; i<3; i++)
- X strcpy (c->leftHUD[i], "");
- X }
- X
- X return 0;
- X}
- X
- Xint doWeaponUpdate (c)
- Xcraft *c; {
- X
- X if (wtbl[c->curWeapon].update != NULL)
- X return (*wtbl[c->curWeapon].update)(c);
- X
- X return 0;
- X}
- *-*-END-of-./fsim/weapon.c-*-*
- echo x - ./fsim/aim9m.c
- sed 's/^X//' >./fsim/aim9m.c <<'*-*-END-of-./fsim/aim9m.c-*-*'
- X/*
- X * xflight : an aerial combat simulator for X
- X *
- X * Written by Riley Rainey, riley@mips.com
- X *
- X * Permission to use, copy, modify and distribute (without charge) this
- X * software, documentation, images, etc. is granted, provided that this
- X * comment and the author's name is retained.
- X *
- X */
- X
- X#include "pm.h"
- X#include <stdio.h>
- X#include <string.h>
- X#include <math.h>
- X
- Xint select_aim9m();
- Xint display_aim9m();
- Xint getIRTarget();
- Xextern int fireMissile ();
- Xextern void createMissileEyeSpace();
- X
- XweaponDesc aim9mDesc = {
- X WK_AIM9M,
- X select_aim9m, /* select */
- X (int (*)()) NULL, /* update */
- X display_aim9m, /* display procedure */
- X fireMissile, /* fire */
- X (int (*)()) NULL, /* fire button release */
- X };
- X
- X/*
- X * aim9m selection function
- X *
- X * A selection function normally determines whether there are any weapons
- X * of this type on-board. If so, and the weapon system is functional
- X * (in other words, undamaged) then return 1; otherwise return 0.
- X */
- X
- Xint select_aim9m (c)
- Xcraft *c; {
- X
- X return 1;
- X
- X}
- X
- X/*
- X * aim9m display function
- X *
- X * Update the HUD display strings associated with this weapon system.
- X */
- X
- Xint display_aim9m (c, w, u)
- Xcraft *c;
- XcraftType *w;
- Xviewer *u; {
- X
- X char s[16];
- X double d, a1, v, r, root1, root2, n, t;
- X VPoint tmp;
- X VMatrix m;
- X int target, count;
- X
- X count = 8;
- X
- X sprintf (s, "%d AIM-9M", count);
- X strcpy (c->leftHUD[1], s);
- X
- X a1 = w->maxThrust / (w->emptyWeight + w->maxFuel) * a;
- X v = mag (c->Cg);
- X a1 -= c->rho * c->cinfo->CDOrigin * v * v;
- X
- X if (c->curRadarTarget >= 0 && a1 != 0.0) {
- X
- X d = c->targetDistance;
- X r = c->targetClosure;
- X
- X n = 4.0 * d / a1 + (r * r) / (a1 * a1);
- X if (n > 0) {
- X n = sqrt (n);
- X root1 = (- r / a + n) / 2.0;
- X root2 = (- r / a - n) / 2.0;
- X if (root1 >= 0.0)
- X if (root2 >= 0.0)
- X if (root1 < root2)
- X t = root1;
- X else
- X t = root2;
- X else
- X t = root1;
- X else if (root2 >= 0.0)
- X t = root2;
- X else
- X t = -1.0;
- X }
- X else
- X t = -1.0;
- X }
- X
- X else
- X t = -1.0;
- X
- X/*
- X * See if the missiles can lock onto any target.
- X */
- X
- X if (count > 0) {
- X createMissileEyeSpace (c, &m);
- X target = getIRTarget (c, &m, &tmp);
- X }
- X else
- X target = -1;
- X
- X if (target >= 0 && t <= 15.0)
- X sprintf (s, "LOCKED %d", (int)(t+0.5));
- X else if (t < 0.0)
- X sprintf (s, "ARM --");
- X else if (t <= 15.0)
- X sprintf (s, "IN RANGE %d", (int)(t+0.5));
- X else
- X sprintf (s, "ARM %d", (int)(t+0.5));
- X
- X strcpy (c->leftHUD[0], s);
- X
- X strcpy (c->leftHUD[2], "");
- X
- X}
- X
- Xextern craftType * newCraft ();
- Xextern char * strdup();
- X
- Xvoid initaim9()
- X{
- X
- X craftType *c;
- X FILE *f;
- X
- X c = newCraft();
- X c->name = strdup("aim-9m");
- X
- X wtbl[0] = aim9mDesc;
- X wtbl[0].w = c;
- X
- X c->CLOrigin = 0.0;
- X c->CLSlope = 4.41235;
- X c->CLNegStall = -15.0 * pi / 180.0;
- X c->CLPosStall = 15.0 * pi / 180.0;
- X
- X c->CDOrigin = 0.1963494; /* 4" radius of body */
- X c->CDFactor = -2.56694;
- X c->CDPhase = 0.0;
- X
- X c->CDBOrigin = 0.0;
- X c->CDBFactor = 0.0;
- X c->CDBPhase = 0.0;
- X
- X c->CMOrigin = 0.0;
- X c->CMFactor = -0.75;
- X
- X c->CNOrigin = 0.0;
- X c->CNFactor = -0.75;
- X
- X VIdentMatrix(&(c->I));
- X c->I.m[0][0] = 0.0;
- X c->I.m[1][1] = 0.0;
- X c->I.m[2][2] = 0.0;
- X c->LDamp = 700000.0;
- X c->MDamp = 1000000.0;
- X c->NDamp = 1000000.0;
- X c->cmSlope = -1.88;
- X c->cmFactor = -1.00;
- X c->cnSlope = 1.00;
- X c->cnFactor = 0.50;
- X c->betaStall = 15.0 * pi / 180.0;
- X
- X c->wingS = 1.0;
- X
- X/*
- X * Assume 150.0 lbs of weight is fuel and that it burns for 20 seconds.
- X * That yields a fuel burn rate of 7.5 lbs/second.
- X */
- X
- X c->emptyWeight = 40.0;
- X c->maxFuel = 150.0;
- X c->maxThrust = 791.0;
- X c->spFuelConsump = 34.134;
- X
- X/*
- X * Three second arming delay
- X */
- X
- X c->armDelay = 3.0;
- X
- X c->groundingPoint.x = 0.0;
- X c->groundingPoint.y = 0.0;
- X c->groundingPoint.z = 0.0;
- X
- X c->viewPoint.x = 0.0;
- X c->viewPoint.y = 0.0;
- X c->viewPoint.z = 0.0;
- X
- X c->crashC = 1.0;
- X
- X c->muStatic = 0.0;
- X c->muKinetic = 0.0;
- X c->muBStatic = 0.0;
- X c->muBKinetic = 0.0;
- X
- X c->maxNWDef = 0.0;
- X c->NWIncr = 0.0;
- X c->maxNWS = 0.0;
- X c->gearD1 = 0.0;
- X c->gearD2 = 0.0;
- X
- X f = fopen ("aim-9", "r");
- X c->object = VReadObject(f);
- X fclose (f);
- X
- X}
- *-*-END-of-./fsim/aim9m.c-*-*
- echo x - ./fsim/bullet
- sed 's/^X//' >./fsim/bullet <<'*-*-END-of-./fsim/bullet-*-*'
- X*a-bullet
- X6 3
- X1 0 0 0
- X2 -0.4 0.5 0
- X3 -19.0 0 0
- X4 -0.4 -0.5 0
- X5 -0.4 0 0.5
- X6 -0.4 0 -0.5
- Xred 4 1 2 3 4
- Xred 4 1 5 3 6
- Xred 4 2 5 4 6
- *-*-END-of-./fsim/bullet-*-*
- echo x - ./fsim/makefile.orig
- sed 's/^X//' >./fsim/makefile.orig <<'*-*-END-of-./fsim/makefile.orig-*-*'
- X#
- X# Makefile for acm; Riley Rainey, 1990
- X#
- XLDFLAGS = -L../V/lib
- XCFLAGS = -g -I../V/lib -systype bsd43
- X
- XOBFILES = server.o \
- X pm.o \
- X flaps.o \
- X droneCalculations.o\
- X init.o \
- X aim9m.o \
- X m61a1.o \
- X weapon.o \
- X newPlayer.o \
- X newPlane.o \
- X missile.o \
- X missileCalculations.o \
- X update.o \
- X doEvents.o \
- X getStick.o \
- X doViews.o \
- X doRadar.o \
- X placeCraft.o \
- X transpose.o \
- X doScale.o
- X
- Xall: acm acms
- X
- Xacm: acm.o
- X cc $(CFLAGS) $(LDFLAGS) -o acm acm.o
- X
- Xacms: $(OBFILES)
- X cc $(CFLAGS) $(LDFLAGS) -o acms $(OBFILES) -lV -lX11 -lm
- X
- Xclean:
- X -rm core *.o
- X
- Xclobber:
- X -rm acm acms *.o core
- X
- Xtar:
- X tar cv acm acms f16 mig23 aim-9 rwy rwy2 tower mtn bullet
- *-*-END-of-./fsim/makefile.orig-*-*
- echo x - ./fsim/V2tgif.c
- sed 's/^X//' >./fsim/V2tgif.c <<'*-*-END-of-./fsim/V2tgif.c-*-*'
- X#include <stdio.h>
- X#include <Vlib.h>
- X
- X#define INCHES 128
- X
- Xint horg = 4 * INCHES;
- Xint vorg = 5 * INCHES;
- Xdouble scale = ((double) INCHES / 4.0); /* 4 feet to the inch */
- X
- X#define XAXIS 1
- X#define YAXIS 2
- X#define ZAXIS 3
- Xint axis = XAXIS;
- X
- Xextern char * optarg;
- X
- Xmain (argc, argv)
- Xint argc;
- Xchar *argv[]; {
- X
- X VObject *object;
- X char *name;
- X FILE *f;
- X int c, i, j, k, n;
- X int v, h;
- X VPoint *q, tmp;
- X VMatrix mtx;
- X VPolygon **p;
- X
- X while ((c = getopt (argc, argv, "f:xyz")) != EOF) {
- X
- X switch (c) {
- X
- X case 'f':
- X name = optarg;
- X break;
- X
- X case 'x':
- X axis = XAXIS;
- X break;
- X
- X case 'y':
- X axis = YAXIS;
- X break;
- X
- X case 'z':
- X axis = ZAXIS;
- X break;
- X }
- X }
- X
- X f = fopen (name, "r");
- X object = VReadObject(f);
- X fclose (f);
- X
- X printf ("state(0,6,0,0,0,16,1,4,1,1,0,0,1,0,1,0,1,0,4).\n");
- X
- X n = object->numPolys;
- X p = object->polygon;
- X for (i=0; i<n; ++i) {
- X printf ("polygon(yellow,%d,[", p[i]->numVtces+1);
- X for ((k=0, q=p[i]->vertex); k<p[i]->numVtces; (++k, ++q)) {
- X transform (q, &v, &h);
- X printf ("%d,%d,", v, h);
- X }
- X transform (p[i]->vertex, &v, &h);
- X printf ("%d,%d],0,0,1,0).\n", v, h);
- X ++j;
- X }
- X
- X exit (0);
- X}
- X
- Xtransform (p, y, x)
- XVPoint *p;
- Xint *y, *x; {
- X
- X double dx, dy;
- X
- X if (axis == XAXIS) {
- X dx = p->y;
- X dy = p->z;
- X }
- X else if (axis == YAXIS) {
- X dx = p->x;
- X dy = p->z;
- X }
- X else if (axis == ZAXIS) {
- X dx = p->x;
- X dy = p->y;
- X }
- X
- X *x = (int) (dx * scale + 0.5) + vorg;
- X *y = (int) (dy * scale + 0.5) + horg;
- X}
- X
- *-*-END-of-./fsim/V2tgif.c-*-*
- exit
- --
- Riley Rainey Internet: riley@mips.com
- MIPS Computer Systems Phone: +1 214 770-7979
- Dallas, Texas
-
- dan
- ----------------------------------------------------
- O'Reilly && Associates argv@sun.com / argv@ora.com
- Opinions expressed reflect those of the author only.
-